package com.ruoyi.project.jiaqin.reportsupply.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.reportsupply.domain.ReportSupply;
import com.ruoyi.project.jiaqin.reportsupply.service.IReportSupplyService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 举报供应Controller
 * 
 * @author admin
 * @date 2020-12-31
 */
@Controller
@RequestMapping("/jiaqin/reportsupply")
public class ReportSupplyController extends BaseController
{
    private String prefix = "jiaqin/reportsupply";

    @Autowired
    private IReportSupplyService reportSupplyService;

    @RequiresPermissions("jiaqin:reportsupply:view")
    @GetMapping()
    public String reportsupply()
    {
        return prefix + "/reportsupply";
    }

    /**
     * 查询举报供应列表
     */
    @RequiresPermissions("jiaqin:reportsupply:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ReportSupply reportSupply)
    {
        startPage();
        List<ReportSupply> list = reportSupplyService.selectReportSupplyList(reportSupply);
        return getDataTable(list);
    }

    /**
     * 导出举报供应列表
     */
    @RequiresPermissions("jiaqin:reportsupply:export")
    @Log(title = "举报供应", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ReportSupply reportSupply)
    {
        List<ReportSupply> list = reportSupplyService.selectReportSupplyList(reportSupply);
        ExcelUtil<ReportSupply> util = new ExcelUtil<ReportSupply>(ReportSupply.class);
        return util.exportExcel(list, "reportsupply");
    }

    /**
     * 新增举报供应
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存举报供应
     */
    @RequiresPermissions("jiaqin:reportsupply:add")
    @Log(title = "举报供应", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ReportSupply reportSupply)
    {
        return toAjax(reportSupplyService.insertReportSupply(reportSupply));
    }

    /**
     * 修改举报供应
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ReportSupply reportSupply = reportSupplyService.selectReportSupplyById(id);
        mmap.put("reportSupply", reportSupply);
        return prefix + "/edit";
    }

    /**
     * 修改保存举报供应
     */
    @RequiresPermissions("jiaqin:reportsupply:edit")
    @Log(title = "举报供应", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ReportSupply reportSupply)
    {
        return toAjax(reportSupplyService.updateReportSupply(reportSupply));
    }

    /**
     * 删除举报供应
     */
    @RequiresPermissions("jiaqin:reportsupply:remove")
    @Log(title = "举报供应", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(reportSupplyService.deleteReportSupplyByIds(ids));
    }
}
